package trial;

import java.util.Scanner;

/**
 * @创建人 MBY381
 * @创建时间 2022/4/15 10:39
 * @描述 美团笔试题
 */
public class MeiTuanCo {
    public static void main(String[] args) {

        test44();
    }


    /**
     * 给俩数让找最小魔法步数
     * 没做对，没有考虑降级越界
     */
    public static void test4() {
        Scanner sc = new Scanner(System.in);
        int m, n;
        //第一行两个空格隔开的正整数A和B表示待操作的数。
        m = sc.nextInt();
        n = sc.nextInt();
        if (m < 0 || n < 0) {
            return;
        }
        if (m == 0) {
            System.out.println(n);
            return;
        } else if (n == 0) {
            System.out.println(m);
            return;
        }

        int ans = 0;
        int max = Math.max(m, n), min = Math.min(m, n);
        int size = max / min;
        while(size>=2&&max>min){
            max=max/2;
            ans=ans+1;
            size = size / 2 + size % 2;
            if(size<2){
                break;
            }
        }
        System.out.println(max + " " + min);
        while (min < max) {

            min++;
            ans++;
        }
        System.out.println(ans);
    }


    static int res = Integer.MAX_VALUE;
    public static void test44() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        dfs(a,b,0);
        System.out.println(res);

    }

    private static void dfs(int a, int b, int i) {
        if(i>=res) return;
        else if(a==b&&i<res){
            res = i;
            return;
        }
        if(a>b){
            int temp = a;
            a = b;
            b = temp;
        }
        dfs(a,b/2,i+1);
        dfs(a*2,b,i+1);
        dfs(a+1,b,i+1);
    }



    public static void test3() {
        Scanner sc = new Scanner(System.in);
        int m, n;
        m = sc.nextInt();
        n = sc.nextInt();
        int[] l = new int[n];
        int[] r = new int[n];
        for (int i = 0; i < n; i++) {
            if (sc.hasNextInt()) {
                l[i] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            if (sc.hasNextInt()) {
                r[i] = sc.nextInt();
            }
        }
        int[] visited = new int[m];
        for (int i = 0; i < n; i++) {
            for (int j = l[i] - 1; j <= r[i] - 1; j++) {
                visited[j]++;
            }
        }
        int ans = 0;
        //之前i写成n边界了
        for (int i = 0; i < m; i++) {
            if (visited[i] > 1) {
                ans++;
            }
        }
        System.out.println(ans);
    }


    public static void test2() {
        Scanner sc = new Scanner(System.in);
        int[] nums = new int[4];
        int index = 0;
        while (index < 4 && sc.hasNextInt()) {
            nums[index] = sc.nextInt();
            index++;
        }
        System.out.println(nums[2] * 60 + nums[3] - nums[0] * 60 - nums[1]);
    }


    public static void test1() {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        if (str.length() == 0) {
            System.out.println(0);
        }
        int ans = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == ' ') {
                ans++;
            }
        }
        System.out.println(ans);

    }


    public static void test() {
        Scanner sc = new Scanner(System.in);
        int a, b;
        while (sc.hasNextLine()) {
            a = sc.nextInt();
            b = sc.nextInt();
            System.out.println(a + b);
        }
    }

}
